<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24"> </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">


      <!-- 高级查询区域 -->
    </div>

    <!-- table区域-begin -->
    <div>
    

      <a-table
        ref="table"
        size="middle"
        :scroll="{ x: true }"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
        class="j-table-force-nowrap"
        @change="handleTableChange"
      >
        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text, record">
          <span v-if="!text" style="font-size: 12px; font-style: italic">无图片</span>
          <img
            v-else
            :src="getImgView(text)"
            :preview="record.id"
            height="25px"
            alt=""
            style="max-width: 80px; font-size: 12px; font-style: italic"
          />
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px; font-style: italic">无文件</span>
          <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a-button type="primary" @click="check(record)"> 检验 </a-button>
        </span>
      </a-table>
    </div>
    <ExamineCompany
      :visible="companyVisible"
      :id="id"
      :recordId="recordId"
      :recordType="recordType"
      @close="close(0)"
    ></ExamineCompany>
    <ExamineProduct
      :visible="productVisible"
      :id="id"
      :recordId="recordId"
      :recordType="recordType"
      @close="close(1)"
    ></ExamineProduct>
    <ExamineCappacity
      :visible="cappacityVisible"
      :id="id"
      :recordId="recordId"
      :recordType="recordType"
      @close="close(2)"
    ></ExamineCappacity>
    <ExamineSupply
      :visible="supplyVisible"
      :id="id"
      :recordId="recordId"
      :recordType="recordType"
      @close="close(3)"
    ></ExamineSupply>
    <!-- <zzzs-examine-modal ref="modalForm" @ok="modalFormOk"></zzzs-examine-modal> -->
  </a-card>
</template>

<script>
import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import ExamineCompany from './modules/ZzzsRecordEnterpriseModalExamine.Style#Drawer'
import ExamineProduct from './modules/ZzzsProductRecordingModaleExamine.Style#Drawer'
import ExamineCappacity from './modules/ZzzsRecordingOfProductionCapacityModalExamine.Style#Drawer'
import ExamineSupply from './modules/ZzzsRecordOfSupplyAbilityModaleExamine.Style#Drawer'

import { filterMultiDictText } from '@/components/dict/JDictSelectUtil'

export default {
  name: 'ZzzsExamineList',
  mixins: [JeecgListMixin, mixinDevice],
  components: { ExamineCompany, ExamineProduct, ExamineCappacity, ExamineSupply },
  data() {
    return {
      description: '审批表管理页面',
      companyVisible: false,
      productVisible: false,
      cappacityVisible: false,
      supplyVisible: false,
      recordType: '',
      id: '',
      recordId: '',
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          },
        },

        {
          title: '审批人',
          align: 'center',
          dataIndex: 'examinePerson_dictText',
        },
        {
          title: '备案类型',
          align: 'center',
          dataIndex: 'recordType_dictText',
        },
        {
          title: '备案id',
          align: 'center',
          dataIndex: 'recordId',
        },
        {
          title: '审批状态',
          align: 'center',
          dataIndex: 'examineStatus_dictText',
        },

        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          fixed: 'right',
          width: 147,
          scopedSlots: { customRender: 'action' },
        },
      ],
      url: {
        list: '/modules/zzzsExamine/examineList',
        delete: '/modules/zzzsExamine/delete',
        deleteBatch: '/modules/zzzsExamine/deleteBatch',
        exportXlsUrl: '/modules/zzzsExamine/exportXls',
        importExcelUrl: 'modules/zzzsExamine/importExcel',
      },
      dictOptions: {},
      superFieldList: [],
    }
  },
  created() {
    this.getSuperFieldList()
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    },
  },
  methods: {
    close(type) {
      if (type == 0) {
        this.companyVisible = false
      } else if (type == 1) {
        this.productVisible = false
      } else if (type == 2) {
        this.cappacityVisible = false
      } else if (type == 3) {
        this.supplyVisible = false
      }
      console.log(2)
      this.loadData()
    },
    initDictConfig() {},
    //检验方法
    check(record) {
      this.id = record.id
      this.recordId = record.recordId
      this.recordType = record.recordType
      if (record.recordType == 0) {
        this.companyVisible = true
      } else if (record.recordType == 1) {
        this.productVisible = true
      } else if (record.recordType == 2) {
        this.cappacityVisible = true
      } else if (record.recordType == 3) {
        this.supplyVisible = true
        console.log(this.supplyVisible)
      }
    },
    getSuperFieldList() {
      let fieldList = []
      fieldList.push({ type: 'int', value: 'examineStatus', text: '审批状态', dictCode: '' })
      fieldList.push({ type: 'string', value: 'examinePerson', text: '审批人', dictCode: '' })
      fieldList.push({ type: 'string', value: 'examineOpinion', text: '审批意见', dictCode: '' })
      fieldList.push({ type: 'int', value: 'recordType', text: '备案类型', dictCode: 'record_type' })
      fieldList.push({ type: 'string', value: 'recordId', text: '备案id', dictCode: '' })
      this.superFieldList = fieldList
    },
  },
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>